package Base;

import common.User;
import global.Const;
import other.HeadImage;

import javax.swing.*;

public class HomePanel extends JPanel {
    JScrollPane scrollPane = new JScrollPane();

    public HomePanel() {
        init();
    }

    private void init() {
        BoxLayout boxLayout = new BoxLayout(this, BoxLayout.Y_AXIS);
        setBounds(0, 0, Const.FRAME_WIDTH, 860);
        scrollPane.setViewportView(this);
        close();
    }

    public JScrollPane getScrollPane() {
        scrollPane.setBounds(0, 0, Const.FRAME_WIDTH, 860);
        return scrollPane;
    }

    public void add(User user, String message) {
        JPanel jpanel = new JPanel();
        jpanel.setLayout(null);
        jpanel.setBounds(0, 0, Const.FRAME_WIDTH, 100);
        jpanel.add(new JLabel(user.username));
        add(new HeadImage(user.username));
    }

    public void open(){
        scrollPane.setVisible(true);
    }

    public void close(){
        scrollPane.setVisible(false);
    }
}
